<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text" id="tex1" />
    <select id="select">//运算符
        <option value="请选择">请选择</option>
        <option value="+">+</option>
        <option value="-">-</option>
        <option value="*">*</option>
        <option value="/">/</option>
    </select>
    
    <input type="text" id="tex2" />
    <input type="button" value=" = " id="btn"/>
    <input type="text" id="fruit"/>



    <script>
    var a = document.getElementById("tex1");//输入第一个值
    var b = document.getElementById("tex2");//输入第二个值
    var selectSign = document.getElementById("select");//操作符
    var bt = document.getElementById("btn");//等于符号
    var m = document.getElementById("fruit");//结果
    
    //a是第一个数
    // b是第二个数
    // bt是操作符
    function count(a,b,bt){
        var res;
        switch (bt){
            case '+': 
                res = a+b;
                break;
            case '-': 
                res = a-b;
                break;
            case '*':
                res = a*b;
                break;
            case '/':
                res = a/b;		
        }
        return res;
    }

    bt.onclick=function(){
        var n1=a.value; //获取第一个数字
        var n2=b.value;//获取第二个数字
        var str=selectSign.value;//获取操作符
        var res2=count(Number(n1),Number(n2),str);
        m.value=res2;
    }


    </script>
</body>
</html>